home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / x / gui / amiga / twm93053.lha / twm / twm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-29  |  12.5 KB  |  364 lines

  1. /*****************************************************************************//**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
  2. /**                          Salt Lake City, Utah                           **/
  3. /**  Portions Copyright 1989 by the Massachusetts Institute of Technology   **/
  4. /**                        Cambridge, Massachusetts                         **/
  5. /**                                                                         **/
  6. /**                           All Rights Reserved                           **/
  7. /**                                                                         **/
  8. /**    Permission to use, copy, modify, and distribute this software and    **/
  9. /**    its documentation  for  any  purpose  and  without  fee is hereby    **/
  10. /**    granted, provided that the above copyright notice appear  in  all    **/
  11. /**    copies and that both  that  copyright  notice  and  this  permis-    **/
  12. /**    sion  notice appear in supporting  documentation,  and  that  the    **/
  13. /**    names of Evans & Sutherland and M.I.T. not be used in advertising    **/
  14. /**    in publicity pertaining to distribution of the  software  without    **/
  15. /**    specific, written prior permission.                                  **/
  16. /**                                                                         **/
  17. /**    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD    **/
  18. /**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **/
  19. /**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR    **/
  20. /**    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **/
  21. /**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **/
  22. /**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
  23. /**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
  24. /**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
  25. /*****************************************************************************/
  26.  
  27.  
  28. /***********************************************************************
  29.  *
  30.  * $XConsortium: twm.h,v 1.74 91/05/31 17:38:30 dave Exp $
  31.  *
  32.  * twm include file
  33.  *
  34.  * 28-Oct-87 Thomas E. LaStrange    File created
  35.  * 10-Oct-90 David M. Sternlicht        Storeing saved colors on root
  36.  ***********************************************************************/
  37.  
  38. #ifndef _TWM_
  39. #define _TWM_
  40.  
  41. #include <X11/Xlib.h>
  42. #include <X11/Xutil.h>
  43. #include <X11/cursorfont.h>
  44. #include <X11/extensions/shape.h>
  45. #include <X11/Xfuncs.h>
  46.  
  47. #ifndef WithdrawnState
  48. #define WithdrawnState 0
  49. #endif
  50.  
  51. typedef unsigned long Pixel;
  52. #define PIXEL_ALREADY_TYPEDEFED        /* for Xmu/Drawing.h */
  53.  
  54. #ifdef SIGNALRETURNSINT
  55. #define SIGNAL_T int
  56. #define SIGNAL_RETURN return 0
  57. #else
  58. #define SIGNAL_T void
  59. #define SIGNAL_RETURN return
  60. #endif
  61.  
  62. typedef SIGNAL_T (*SigProc)();    /* type of function returned by signal() */
  63.  
  64. #define BW 2            /* border width */
  65. #define BW2 4            /* border width  * 2 */
  66.  
  67. #ifndef TRUE
  68. #define TRUE    1
  69. #define FALSE    0
  70. #endif
  71.  
  72. #define NULLSTR ((char *) NULL)
  73.  
  74. #define MAX_BUTTONS    5    /* max mouse buttons supported */
  75.  
  76. /* info stings defines */
  77. #define INFO_LINES 30
  78. #define INFO_SIZE 200
  79.  
  80. /* contexts for button presses */
  81. #define C_NO_CONTEXT    -1
  82. #define C_WINDOW    0
  83. #define C_TITLE        1
  84. #define C_ICON        2
  85. #define C_ROOT        3
  86. #define C_FRAME        4
  87. #define C_ICONMGR    5
  88. #define C_NAME        6
  89. #define C_IDENTIFY      7
  90. #define NUM_CONTEXTS    8
  91.  
  92. #define C_WINDOW_BIT    (1 << C_WINDOW)
  93. #define C_TITLE_BIT    (1 << C_TITLE)
  94. #define C_ICON_BIT    (1 << C_ICON)
  95. #define C_ROOT_BIT    (1 << C_ROOT)
  96. #define C_FRAME_BIT    (1 << C_FRAME)
  97. #define C_ICONMGR_BIT    (1 << C_ICONMGR)
  98. #define C_NAME_BIT    (1 << C_NAME)
  99.  
  100. #define C_ALL_BITS    (C_WINDOW_BIT | C_TITLE_BIT | C_ICON_BIT |\
  101.              C_ROOT_BIT | C_FRAME_BIT | C_ICONMGR_BIT)
  102.  
  103. /* modifiers for button presses */
  104. #define MOD_SIZE    ((ShiftMask | ControlMask | Mod1Mask \
  105.               | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) + 1)
  106.  
  107. #define TITLE_BAR_SPACE         1    /* 2 pixel space bordering chars */
  108. #define TITLE_BAR_FONT_HEIGHT   15    /* max of 15 pixel high chars */
  109. #define TITLE_BAR_HEIGHT        (TITLE_BAR_FONT_HEIGHT+(2*TITLE_BAR_SPACE))
  110.  
  111. /* defines for zooming/unzooming */
  112. #define ZOOM_NONE 0
  113.  
  114. #define FBF(fix_fore, fix_back, fix_font)\
  115.     Gcv.foreground = fix_fore;\
  116.     Gcv.background = fix_back;\
  117.     Gcv.font = fix_font;\
  118.     XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv)
  119.  
  120. #define FB(fix_fore, fix_back)\
  121.     Gcv.foreground = fix_fore;\
  122.     Gcv.background = fix_back;\
  123.     XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground,&Gcv)
  124.  
  125. typedef struct MyFont
  126. {
  127.     char *name;            /* name of the font */
  128.     XFontStruct *font;        /* font structure */
  129.     int height;            /* height of the font */
  130.     int y;            /* Y coordinate to draw characters */
  131. } MyFont;
  132.  
  133. typedef struct ColorPair
  134. {
  135.     Pixel fore, back;
  136. } ColorPair;
  137.  
  138. typedef struct _TitleButton {
  139.     struct _TitleButton *next;        /* next link in chain */
  140.     char *name;                /* bitmap name in case of deferal */
  141.     Pixmap bitmap;            /* image to display in button */
  142.     int srcx, srcy;            /* from where to start copying */
  143.     unsigned int width, height;        /* size of pixmap */
  144.     int dstx, dsty;            /* to where to start copying */
  145.     int func;                /* function to execute */
  146.     char *action;            /* optional action arg */
  147.     struct MenuRoot *menuroot;        /* menu to pop on F_MENU */
  148.     Bool rightside;            /* t: on right, f: on left */
  149. } TitleButton;
  150.  
  151. typedef struct _TBWindow {
  152.     Window window;            /* which window in this frame */
  153.     TitleButton *info;            /* description of this window */
  154. } TBWindow;
  155.  
  156. typedef struct _SqueezeInfo {
  157.     int justify;            /* left, center, right */
  158.     int num;                /* signed pixel count or numerator */
  159.     int denom;                /* 0 for pix count or denominator */
  160. } SqueezeInfo;
  161.  
  162. #define J_LEFT            1
  163. #define J_CENTER        2
  164. #define J_RIGHT            3
  165.  
  166. /* Colormap window entry for each window in WM_COLORMAP_WINDOWS
  167.  * ICCCM property.
  168.  */
  169. typedef struct TwmColormap
  170. {    
  171.     Colormap c;            /* Colormap id */
  172.     int state;            /* install(ability) state */
  173.     unsigned long install_req;    /* request number which installed it */
  174.     Window w;            /* window causing load of color table */
  175.     int refcnt;
  176. } TwmColormap;
  177.  
  178. #define CM_INSTALLABLE        1
  179. #define CM_INSTALLED        2
  180. #define CM_INSTALL        4
  181.  
  182. typedef struct ColormapWindow
  183. {
  184.     Window w;            /* Window id */
  185.     TwmColormap *colormap;    /* Colormap for this window */
  186.     int visibility;        /* Visibility of this window */
  187.     int refcnt;
  188. } ColormapWindow;
  189.  
  190. typedef struct Colormaps
  191. {
  192.     ColormapWindow **cwins;    /* current list of colormap windows */
  193.     int number_cwins;        /* number of elements in current list */
  194.     char *scoreboard;        /* conflicts between installable colortables */
  195. } Colormaps;
  196.  
  197. #define ColormapsScoreboardLength(cm) ((cm)->number_cwins * \
  198.                        ((cm)->number_cwins - 1) / 2)
  199.  
  200. /* for each window that is on the display, one of these structures
  201.  * is allocated and linked into a list 
  202.  */
  203. typedef struct TwmWindow
  204. {
  205.     struct TwmWindow *next;    /* next twm window */
  206.     struct TwmWindow *prev;    /* previous twm window */
  207.     Window w;            /* the child window */
  208.     int old_bw;            /* border width before reparenting */
  209.     Window frame;        /* the frame window */
  210.     Window title_w;        /* the title bar window */
  211.     Window hilite_w;        /* the hilite window */
  212.     Pixmap gray;
  213.     Window icon_w;        /* the icon window */
  214.     Window icon_bm_w;        /* the icon bitmap window */
  215.     int frame_x;        /* x position of frame */
  216.     int frame_y;        /* y position of frame */
  217.     int frame_width;        /* width of frame */
  218.     int frame_height;        /* height of frame */
  219.     int frame_bw;        /* borderwidth of frame */
  220.     int title_x;
  221.     int title_y;
  222.     int icon_x;            /* icon text x coordinate */
  223.     int icon_y;            /* icon text y coordiante */
  224.     int icon_w_width;        /* width of the icon window */
  225.     int icon_w_height;        /* height of the icon window */
  226.     int icon_width;        /* width of the icon bitmap */
  227.     int icon_height;        /* height of the icon bitmap */
  228.     int title_height;        /* height of the title bar */
  229.     int title_width;        /* width of the title bar */
  230.     char *full_name;        /* full name of the window */
  231.     char *name;            /* name of the window */
  232.     char *icon_name;        /* name of the icon */
  233.     int name_width;        /* width of name text */
  234.     int highlightx;        /* start of highlight window */
  235.     int rightx;            /* start of right buttons */
  236.     XWindowAttributes attr;    /* the child window attributes */
  237.     XSizeHints hints;        /* normal hints */
  238.     XWMHints *wmhints;        /* WM hints */
  239.     Window group;        /* group ID */
  240.     XClassHint class;
  241.     struct WList *list;
  242.     /***********************************************************************
  243.      * color definitions per window
  244.      **********************************************************************/
  245.     Pixel border;        /* border color */
  246.     Pixel icon_border;        /* border color */
  247.     ColorPair border_tile;
  248.     ColorPair title;
  249.     ColorPair iconc;
  250.     short iconified;        /* has the window ever been iconified? */
  251.     short icon;            /* is the window an icon now ? */
  252.     short icon_on;        /* is the icon visible */
  253.     short mapped;        /* is the window mapped ? */
  254.     short auto_raise;        /* should we auto-raise this window ? */
  255.     short forced;        /* has had an icon forced upon it */
  256.     short icon_not_ours;    /* icon pixmap or window supplied to us */
  257.     short icon_moved;        /* user explicitly moved the icon */
  258.     short highlight;        /* should highlight this window */
  259.     short stackmode;        /* honor stackmode requests */
  260.     short iconify_by_unmapping;    /* unmap window to iconify it */
  261.     short iconmgr;        /* this is an icon manager window */
  262.     short transient;        /* this is a transient window */
  263.     Window transientfor;    /* window contained in XA_XM_TRANSIENT_FOR */
  264.     short titlehighlight;    /* should I highlight the title bar */
  265.     struct IconMgr *iconmgrp;    /* pointer to it if this is an icon manager */
  266.     int save_frame_x;        /* x position of frame */
  267.     int save_frame_y;        /* y position of frame */
  268.     int save_frame_width;    /* width of frame */
  269.     int save_frame_height;    /* height of frame */
  270.     short zoomed;        /* is the window zoomed? */
  271.     short wShaped;        /* this window has a bounding shape */
  272.     unsigned long protocols;    /* which protocols this window handles */
  273.     Colormaps cmaps;        /* colormaps for this application */
  274.     TBWindow *titlebuttons;
  275.     SqueezeInfo *squeeze_info;    /* should the title be squeezed? */
  276.     struct {
  277.     struct TwmWindow *next, *prev;
  278.     Bool cursor_valid;
  279.     int curs_x, curs_y;
  280.     } ring;
  281. } TwmWindow;
  282.  
  283. #define DoesWmTakeFocus        (1L << 0)
  284. #define DoesWmSaveYourself    (1L << 1)
  285. #define DoesWmDeleteWindow    (1L << 2)
  286.  
  287. #define TBPM_DOT ":dot"        /* name of titlebar pixmap for dot */
  288. #define TBPM_ICONIFY ":iconify"    /* same image as dot */
  289. #define TBPM_RESIZE ":resize"    /* name of titlebar pixmap for resize button */
  290. #define TBPM_XLOGO ":xlogo"    /* name of titlebar pixmap for xlogo */
  291. #define TBPM_DELETE ":delete"    /* same image as xlogo */
  292. #define TBPM_MENU ":menu"    /* name of titlebar pixmap for menus */
  293. #define TBPM_QUESTION ":question"    /* name of unknown titlebar pixmap */
  294.  
  295. #include <X11/Xosdefs.h>
  296. #ifndef X_NOT_STDC_ENV
  297. #include <stdlib.h>
  298. #else
  299. extern char *malloc(), *calloc(), *realloc(), *getenv();
  300. extern void free();
  301. #endif
  302. extern void Reborder();
  303. extern SIGNAL_T Done();
  304. void ComputeCommonTitleOffsets();
  305. void ComputeWindowTitleOffsets(), ComputeTitleLocation();
  306. extern char *ProgramName;
  307. extern Display *dpy;
  308. extern Window ResizeWindow;    /* the window we are resizing */
  309. extern int HasShape;        /* this server supports Shape extension */
  310.  
  311. extern int PreviousScreen;
  312.  
  313. extern Cursor UpperLeftCursor;
  314. extern Cursor RightButt;
  315. extern Cursor MiddleButt;
  316. extern Cursor LeftButt;
  317.  
  318. extern XClassHint NoClass;
  319.  
  320. extern XContext TwmContext;
  321. extern XContext MenuContext;
  322. extern XContext IconManagerContext;
  323. extern XContext ScreenContext;
  324. extern XContext ColormapContext;
  325.  
  326. extern char *Home;
  327. extern int HomeLen;
  328. extern int ParseError;
  329.  
  330. extern int HandlingEvents;
  331.  
  332. extern Window JunkRoot;
  333. extern Window JunkChild;
  334. extern int JunkX;
  335. extern int JunkY;
  336. extern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask;
  337. extern XGCValues Gcv;
  338. extern int InfoLines;
  339. extern char Info[][INFO_SIZE];
  340. extern int Argc;
  341. extern char **Argv;
  342. extern char **Environ;
  343. extern void NewFontCursor();
  344. extern Pixmap CreateMenuIcon();
  345.  
  346. extern Bool ErrorOccurred;
  347. extern XErrorEvent LastErrorEvent;
  348.  
  349. #define ResetError() (ErrorOccurred = False)
  350.  
  351. extern Bool RestartPreviousState;
  352. extern Bool GetWMState();
  353.  
  354. extern Atom _XA_MIT_PRIORITY_COLORS;
  355. extern Atom _XA_WM_CHANGE_STATE;
  356. extern Atom _XA_WM_STATE;
  357. extern Atom _XA_WM_COLORMAP_WINDOWS;
  358. extern Atom _XA_WM_PROTOCOLS;
  359. extern Atom _XA_WM_TAKE_FOCUS;
  360. extern Atom _XA_WM_SAVE_YOURSELF;
  361. extern Atom _XA_WM_DELETE_WINDOW;
  362.  
  363. #endif /* _TWM_ */
  364.